﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace MvcWiki.Repository.FileSystem
{
    public class FileSystemWrapper : IFileSystemWrapper
    {
        public bool FileExists(string path)
        {
            return File.Exists(path);
        }

        public string ReadFromFile(string path)
        {
            return File.ReadAllText(path);
        }

        public void WriteToFile(string path, string contents)
        {
            File.WriteAllText(path, contents);
        }

        public string[] GetFiles(string path, string searchPattern)
        {
            return Directory.GetFiles(path, searchPattern, SearchOption.TopDirectoryOnly);
        }

        public void CreateDirectory(string path)
        {
            Directory.CreateDirectory(path);
        }

        public string[] GetDirectories(string path, string searchPattern)
        {
            return Directory.GetDirectories(path, searchPattern, SearchOption.TopDirectoryOnly);
        }

        public void MoveDirectory(string sourceDirName, string destDirName)
        {
            Directory.Move(sourceDirName, destDirName);
        }

        public void DeleteFile(string path)
        {
            File.Delete(path);
        }

        public void DeleteDirectory(string path)
        {
            Directory.Delete(path, true);
        }
    }
}
